﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;

namespace BlueCMS.Core.Controls
{
    public class MenuItem : WebControl, INamingContainer
    {
        private ImageButton mImageButton;
        private LinkButton mLinkButton;

        public MenuItem()
        {
            mImageButton = new ImageButton();
            mLinkButton = new LinkButton();
            mImageButton.ImageAlign = ImageAlign.AbsMiddle;
            mLinkButton.Style.Add("color", "#000000");
            mLinkButton.Style.Add("text-decoration", "none");
        }

        //public string CssClass { get; set; }

        public string ImageUrl
        {
            get { return mImageButton.ImageUrl; }
            set { mImageButton.ImageUrl = value; }
        }

        public string Text
        {
            get { return mLinkButton.Text; }
            set { mLinkButton.Text = value; mImageButton.AlternateText = value; }
        }

        protected override void CreateChildControls()
        {
            HtmlGenericControl div = new HtmlGenericControl("div");
            if (CssClass.Length > 0)
            {
                div.Attributes.Add("class", CssClass);
            }
            div.Controls.Add(mImageButton);
            div.Controls.Add(new LiteralControl("&nbsp;"));
            div.Controls.Add(mLinkButton);
            Controls.Add(div);
        }
    }
}
